import axios from 'axios'

import TAddress from './mapData/TAddress'

const pre = '/dataApi/ws/place/'
const tencentAK = 'HFFBZ-I62WQ-MX35Y-4T5HB-3SX55-QPBTM'

// 城市查询
export const getCollegeInfoByRegion = async (keyword, categoryCode, region) => {
  const url =
    pre +
    '/v1/search?' +
    'filter=category=' +
    categoryCode +
    '&boundary=region(' +
    region.city +
    ',1,' +
    region.lat +
    ',' +
    region.lng +
    ')&keyword=' +
    keyword +
    '&key=' +
    tencentAK
  return await axios.get(url).then((res) => {
    return res.data.data.map((item) => {
      return new TAddress(item)
    })
  })
}
